import pandas as pd


def get_letter_num(string, letter):
    return string.count(letter, 0)


def if_letter_more(string, letter):
    return get_letter_num(string, letter) > 1


if __name__ == '__main__':
    excel_path = '选择题.xlsx'
    data = pd.read_excel(excel_path, sheet_name='data')
    column = ['类型', '题目', '答案', '分数', '选项']
    test_data = []
    for i in data.index.values:  # 获取行号的索引，并对其进行遍历：
        # 根据i来获取每一行指定的数据 并利用to_dict转成字典
        row_data = data.loc[i, column].to_dict()
        test_data.append(row_data)
    for question in test_data:
        # print(question)
        # if "A" in question['题目'] or "B" in question['题目']or "C" in question['题目']or "D" in question['题目']:
        #     print(question)
        if if_letter_more(question['选项'], "A") or if_letter_more(question['选项'], "B") or \
                if_letter_more(question['选项'], "C") or if_letter_more(question['选项'], "D") > 1:
            print(question)
